package com.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnection {
    private final static String DRIVER = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; // 驱动字符串
    private final static String URL = "jdbc:microsoft:sqlserver://";  // 连接字符串
    private final static String HOST = "192.168.1.190";  // 连接到的主机
    private final static String PORT = "1433";  // 端口号
    private final static String DBNAME = "hjc";  // 数据库名称
    private final static String USER = "sa";  // 数据库用户名
    private final static String PASSWORD = "sa";  // 数据库密码

    // 建立与数据库的连接
     public Connection getConnection() throws SQLException {
        return DriverManager.getConnection(URL + HOST + ":" + PORT + ";databaseName=" + DBNAME, USER, PASSWORD);
    }
}